Component({
  properties: {
    flag: String,
    image: String,
    title: String,
    price: String,
    quantity: {
      type: Number,
      value: 1
    },
    checked: {
      type: Boolean,
      value: false
    },
    id: String
  },
  methods: {
    gotodetail() {
      this.triggerEvent('gotodetail', { title: this.data.title, image: this.data.image, price: this.data.price });
    },
    CheckChange(e) {
      this.setData({
        checked:this.data.checked==true?false:true
      })
      console.log(this.data.checked)
      this.triggerEvent('checkchange', { title:e.detail.value[0],checked:this.data.checked});
    },
    add() {
      this.triggerEvent('quantitychange', { id: this.data.title, quantity: this.data.quantity+1});
    },
    sub() {
      if (this.data.quantity > 0) {
        this.triggerEvent('quantitychange', { id: this.data.title, quantity: this.data.quantity-1});
      }
    }
  }
});